home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-10-26 | 1.1 KB | 47 lines | [TEXT/CWIE] |
- #include <iostream.h>
-
-
- //--------------------------------------- Item
-
- class Item
- {
- private:
- float price;
-
- public:
- Item( float itemPrice );
- // Note that the default value for taxRate has been removed. The book
- // uses a default value of 0. As it turns out, section 13,5 of
- // the ANSI C++ draft states that an operator function cannot have
- // default arguments. This faulty code compiled under THIN C++ but
- // was tripped up by the CodeWarrior compiler.
- //
- // In this version, I just removed the default value for taxRate
- // and changed the call stimpyDoll() to stimpyDoll( 0 ) to
- // achieve the same result. Thanks to Khurram Quereshi for figuring
- // this one out!! -- Dave Mark, 10/26/95
- float operator()( float taxRate );
- };
-
- Item::Item( float itemPrice )
- {
- price = itemPrice;
- }
-
- float Item::operator()( float taxRate )
- {
- return( ((taxRate * .01) + 1) * price );
- }
-
-
- //--------------------------------------- main()
-
- int main()
- {
- Item stimpyDoll( 36.99 );
-
- cout << "Price of Stimpy doll: $" << stimpyDoll( 0 );
- cout << "\nPrice with 4.5% tax: $" << stimpyDoll( 4.5 );
-
- return 0;
- }